package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 徒有琴
 * 11111
 * 22222
 *
 */
@Controller
public class ExceptionController {
    @RequestMapping("/ex.html")
    public String exceptionTest(Integer type) throws Exception {
        //手动抛出几个异常，模拟程序中可能出现的异常
        switch (type) {
            case 1:
                throw new NullPointerException("测试空指针异常");
                //我是另一个人
            case 2:
                throw new ClassCastException("测试类型转换异常");
            case 3:
                throw new IndexOutOfBoundsException("测试越界异常");
        }
        return "index";
    }
}
